<?php
namespace cubox\database;
//AI写的，还没测试
use cubox\Database;
use cubox\provider\PDO;

class Sqlite extends Database
{
     
    use PDO;

    public function escapeName($name):string
    {
        return '`'.str_replace('`', '``', $name).'`';
    }

    public function escapeValue($value):string
    {
        if(is_bool($value)) {
            return $value? 1 : 0;
        }
        if(is_null($value)) {
            return 'NULL';
        }
        if(is_int($value) || is_float($value)) {
            return $value;
        }
        if(is_string($value)) {
            return "'".$this->connection->quote($value)."'";
        }
    }

    public static function configParams(): array
    {
        return [
            'path' => [
                'input' =>'input',
                'default' => 'sqlite.db',
                'description' => 'SQLite database file path.',
            ],
        ];
    }
}